
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* LScript.js
**/
function LScript(scriptLayer,value){
	var self = this;
	LGlobal.script = self;
	self.scriptLayer = scriptLayer;
	LGlobal.stage = scriptLayer.stage;
	self.scriptArray = new LScriptArray();
	self.scriptArray.layerList["-"] = scriptLayer;

	self.dataList = new Array();
	value = self.removeComment(value);
	var arr=[value];
	self.dataList.unshift(arr);
	self.toList(value);
}
LScript.prototype = {
	removeComment:function(str){
		var self = this;
		var sIndex;
		var eIndex;
		var sStr;
		var eStr;
		sIndex = str.indexOf("/*");
		while(sIndex >=0){
			eIndex = str.indexOf("*/",sIndex + 2);
			sStr = str.substr(0,sIndex);
			eStr = str.substr(eIndex + 2);
			str = sStr + eStr;
			sIndex = str.indexOf("/*");
		}
			
		sIndex = str.indexOf("//");
		while(sIndex >=0){
			eIndex = str.indexOf("\n",sIndex);
			if(eIndex >= 0){
				sStr = str.substr(0,sIndex);
				eStr = str.substr(eIndex);
				str = sStr + eStr;
				sIndex = str.indexOf("//");
			}else{
				sStr = str.substr(0,sIndex);
				str = sStr;
				sIndex = -1;
			}
		}
		return str;
	},
	toList:function(ltxt){
		var self = this;
		self.lineList = ltxt.split(";");
		if(LGlobal.isreading && LGlobal.isreading.length > 0){
			self.lineList.unshift("Mark.goto("+LGlobal.isreading+")");
			LGlobal.isreading = "";
		}
		self.copyList = self.lineList.slice(0);
		self.analysis();
	},
	saveList:function(){
		var self = this;
		var arr=self.dataList[0];
		if(arr){
			arr[1]=self.lineList;
			arr[2]=self.copyList;
		}
	},
	analysis:function(){
		var self = this;
		var arr;
		if(self.lineList.length == 0){
			self.dataList.shift();
			if(self.dataList.length > 0){
				arr=self.dataList[0];
				self.lineList = arr[1];
				self.copyList = arr[2];
				self.analysis();
			}
			return;
		}
		var lineValue = "";
		while(self.lineList.length > 0 && lineValue.length == 0){
			lineValue = LMath.trim(self.lineList[0]);
			self.lineList.shift();
		}
		if(lineValue.length == 0){
			self.analysis();
			return;
		}
		lineValue = ScriptVarlable.getVarlable(lineValue);
		trace("analysis lineValue = " + lineValue);
		var sarr = lineValue.split(".");
		switch(sarr[0]){
			case "Var":
				ScriptVarlable.analysis(lineValue);
				break;
			case "Load":
				ScriptLoad.analysis(lineValue);
				break;
			case "Layer":
				ScriptLayer.analysis(lineValue);
				break;
			case "Text":
				ScriptText.analysis(lineValue);
				break;
			case "Img":
				ScriptImg.analysis(lineValue);
				break;
			case "Call":
				ScriptFunction.analysis(lineValue);
				break;
			case "Button":
				ScriptButton.analysis(lineValue);
				break;
			default:
				if(lineValue.indexOf("if") >= 0){
					ScriptIF.getIF(lineValue);
				}else if(lineValue.indexOf("function") >= 0){
					ScriptFunction.setFunction(lineValue);
				}
				/*else if(lineValue.indexOf("SouSou") == 0){
					LScriptSLGSouSou.analysis(sarr[0],lineValue);
				}*/
				else{
					self.childAnalysis(sarr[0],lineValue);
				}
		}
		
	},
	childAnalysis:function(childType,lineValue){
		self.analysis();
	}
};


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* LScriptArray.js
**/
function LScriptArray(){
	var self = this;
	//用来保存LTextField对象
	self.textList = new Array();
	//用来保存LSprite对象
	self.layerList = new Array();
	//用来保存变量
	self.varList = new Array();
	//用来保存函数
	self.funList = new Array();
	//用来保存LBitmapData对象
	self.bitmapdataList = new Array();
	//用来保存LBitmap对象
	self.imgList = new Array();
	self.btnList = new Array();
	self.radioList = new Array();
	self.comboBoxList = new Array();
	self.animationList = new Array();

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptVarlable.js
**/
var ScriptVarlable = function (){};
ScriptVarlable.analysis = function (value){
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	switch(value.substr(0,start)){
		case "Var.set":
			ScriptVarlable.setVarlable(value,start,end);
			break;
		default:
			LGlobal.script.analysis();
	}
};
ScriptVarlable.setVarlable = function (value,start,end){
	var script = LGlobal.script;
	var lArr = value.substring(start+1,end).split(",");
	script.scriptArray.varList[lArr[0]] = lArr[1];
	script.analysis();
};
ScriptVarlable.getVarlable = function (str){
	var script = LGlobal.script;
	var iIndex = 0;
	var sIndex;
	var eIndex;
	var sStr;
	var eStr;
	var vStr;
	var result = "";
	var r=/^([a-z]|[A-Z]|_)+$/;
	sIndex = str.indexOf("@");
	while(sIndex >=0){
		eIndex = str.indexOf("@",sIndex+1);
		if(sIndex + 1 == eIndex){
			sStr = str.substr(iIndex,sIndex);
			vStr = "@";
			eStr = str.substr(eIndex + 1);
			iIndex = eIndex + 1;
		}else{
			sStr = str.substring(iIndex,sIndex);
			vStr = "";
			sIndex++;
			while(r.exec(str.charAt(sIndex))){
				vStr += str.charAt(sIndex);
				sIndex++;
			}
			vStr = script.scriptArray.varList[vStr];
			eStr = str.substr(sIndex);
			iIndex = sIndex;
		};
		result += (sStr + vStr);
		sIndex = str.indexOf("@",iIndex);
	}
	result += str.substr(iIndex);
	return result;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptLoad.js
**/
var ScriptLoad = function (){};
ScriptLoad.data = "";
ScriptLoad.urlloader = null;
ScriptLoad.loader = null;
ScriptLoad.analysis = function (value){
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	ScriptLoad.data = value.substring(start+1,end).split(",");
	switch(LMath.trim(value.substr(0,start))){
		case "Load.img":
			ScriptLoad.loadImg();
			break;
		case "Load.script":
			ScriptLoad.loadScript();
			break;
		case "Load.swf":
			//ScriptLoad.loadSwf();
			break;
		default:
			LGlobal.script.analysis();
	}
};
ScriptLoad.loadImg = function (){
	ScriptLoad.loader = new LLoader();
	ScriptLoad.loader.addEventListener(LEvent.COMPLETE,ScriptLoad.loadImgOver);
	ScriptLoad.loader.load(ScriptLoad.data[1],"bitmapData");
};
ScriptLoad.loadImgOver = function (event){
	var script = LGlobal.script;
	script.scriptArray.bitmapdataList[ScriptLoad.data[0]] = new LBitmapData(ScriptLoad.loader.content);
	ScriptLoad.loader.imgLoader = null;
	script.analysis();
};
ScriptLoad.loadScript = function (){
	ScriptLoad.urlloader = new LURLLoader();
	ScriptLoad.urlloader.addEventListener(LEvent.COMPLETE,ScriptLoad.loadScriptOver);
	ScriptLoad.urlloader.load(ScriptLoad.data[0],"text");
};
ScriptLoad.loadScriptOver = function (event){
	var script = LGlobal.script;
	var data = script.removeComment(event.target.data);
	ScriptLoad.urlloader.die();
	ScriptLoad.urlloader = null;
	script.saveList();
	script.dataList.unshift([data]);
	script.toList(data);
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptLayer.js
**/
var ScriptLayer = function (){};
ScriptLayer.analysis = function (value){
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	switch(value.substr(0,start)){
		case "Layer.add":
			//setLayer(value,start,end);
			break;
		case "Layer.remove":
			//removeLayer(value,start,end);
			break;
		case "Layer.transition":
			//transition(value,start,end);
			break;
		case "Layer.setFilter":
			//setFilter(value,start,end);
			break;
		case "Layer.clear":
			ScriptLayer.clearLayer(value,start,end);
			break;
		case "Layer.drawRect":
			ScriptLayer.drawRect(value,start,end);
			break;
		case "Layer.drawRoundRect":
			//drawRoundRect(value,start,end);
			break;
		case "Layer.drawRectLine":
			ScriptLayer.drawRectLine(value,start,end);
			break;
		case "Layer.drawRoundRectLine":
			ScriptLayer.drawRectLine(value,start,end);
			//drawRoundRectLine(value,start,end);
			break;
		case "Layer.drawRectGradient":
			ScriptLayer.drawRectGradient(value,start,end);
			//LGlobal.script.analysis();
			/*var canvas=document.getElementById("myCanvas");
var ctx=canvas.getContext("2d");
var grd=ctx.createLinearGradient(0,0,150,0);
grd.addColorStop(0.3,"red");
grd.addColorStop(0.7,"green");
ctx.fillStyle=grd;
ctx.fillRect(0,0,150,100);*/
			//drawRectGradient(value,start,end);
			break;
		case "Layer.drawTriangle":
			//drawTriangle(value,start,end);
			break;
		case "Layer.drawTriangleLine":
			//drawTriangle(value,start,end);
			break;
		default:
	}
};
ScriptLayer.drawRectGradient = function (value,start,end){
	//Layer.drawRectGradient(-,0,0,600,100,0xa6ffff,0xffffff)
	var params = value.substring(start+1,end).split(",");
	var nameStr = params[0];
	var sx = params[1];
	var sy = params[2];
	var ex = params[3];
	var ey = params[4];
	var color1 = params[5];
	var color2 = params[6];
	color1 = color1.replace("0x","#");
	color2 = color2.replace("0x","#");
	var fun = function (){
		var grd=LGlobal.canvas.createLinearGradient(sx,sy,sx,ey);
		grd.addColorStop(0.3,color1);
		grd.addColorStop(0.7,color2);
		LGlobal.canvas.fillStyle=grd;
		LGlobal.canvas.fillRect(sx,sy,ex,ey);
	};
	var script = LGlobal.script;
	var layer = script.scriptArray.layerList[nameStr];
	layer.graphics.add(fun);
	script.analysis();
};
ScriptLayer.drawRect = function (value,start,end){
	var params = value.substring(start+1,end).split(",");
	var nameStr = params[0];
	var color = params[5];
	color = color.replace("0x","#");
	var alpha = parseFloat(params[6]);
	var script = LGlobal.script;
	var layer = script.scriptArray.layerList[nameStr];
	//LDisplay.drawRect(layer.graphics,[parseInt(params[1]),parseInt(params[2]),parseInt(params[3]),parseInt(params[4])],true,color,alpha);
	script.analysis();
};
ScriptLayer.drawRectLine = function (value,start,end){
	var params = value.substring(start+1,end).split(",");
	var nameStr = params[0];
	var color = params[5];
	color = color.replace("0x","#");
	var alpha = parseFloat(params[6]);
	var script = LGlobal.script;
	var layer = script.scriptArray.layerList[nameStr];
	//LDisplay.drawRect(layer.graphics,[parseInt(params[1]),parseInt(params[2]),parseInt(params[3]),parseInt(params[4])],false,color,alpha);
	script.analysis();
};
ScriptLayer.clearLayer = function (value,start,end){
	var nameStr = LMath.trim(value.substring(start+1,end));
	var script = LGlobal.script;
	var layer;
	layer = script.scriptArray.layerList[nameStr];
	if(layer == null){
		script.analysis();
		return;
	}
	ScriptLayer.removeFromArray(layer);
	layer.die();
	layer.removeAllChild();
	
	script.analysis();
};
ScriptLayer.removeFromArray = function (obj){
	if(obj.childList == null)return;
	var count = obj.childList.length;
	for(var i = 0; i < count; i++){
		if(obj.type == "LSprite"){
			ScriptLayer.removeFromArray(obj.getChildAt(i));
		}else if(obj.type == "LButton"){
			LGlobal.script.scriptArray.btnList[obj.getChildAt(i).name] = null;
		}else if(obj.type == "LBitmap"){
			LGlobal.script.scriptArray.imgList[obj.getChildAt(i).name] = null;
		}else if(obj.type == "LTextField"){
			LGlobal.script.scriptArray.textList[obj.getChildAt(i).name] = null;
		}else if(obj.type == "LRadio"){
			//LGlobal.script.scriptArray.radioList[obj.getChildAt(i).name] = null;
		}
	}
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptText.js
**/
var ScriptText = function (){};
ScriptText.analysis = function (value){
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	ScriptLoad.data = value.substring(start+1,end).split(",");
	switch(LMath.trim(value.substr(0,start))){
		case "Text.label":
			ScriptLabel.analysis(value,start,end);
			break;
		default:
			LGlobal.script.analysis();
	}
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptLabel.js
**/
var ScriptLabel = function (){};
ScriptLabel.analysis = function (value,start,end){
	var script = LGlobal.script;
	var lArr = value.substring(start+1,end).split(",");
	var layer,label,i;
	var layerStr = lArr[0];
	var nameStr = lArr[1];
	var textStr = lArr[2];
	layer = script.scriptArray.layerList[layerStr];
	var textArr = textStr.split("\\n");
	//while(textStr.indexOf("\\n")>=0)textStr = textStr.replace("\\n","\n");
	for(i=0;i<textArr.length;i++){
		label = new LLabel();
		label.size = lArr[5]-4;
		label.color = lArr[6];
		label.text = textArr[i];
		label.x = parseInt(lArr[3]);
		label.y = parseInt(lArr[4]) + (label.height - 2) * i;
		if(lArr.length > 7 && parseInt(lArr[7]) == 1){
			label.stroke = true;
			label.lineWidth = 2;
		}
		label.name = nameStr;
		layer.addChild(label);
	}
	script.scriptArray.textList[nameStr] = textArr;
	script.analysis();
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptFunction.js
**/
var ScriptFunction = function (){};
ScriptFunction.analysis = function (value){
	var script = LGlobal.script;
	var point = value.indexOf(".");
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	var name = value.substring(point + 1,start);
	var funArr = script.scriptArray.funList[name];
	if(funArr == null){
		script.analysis();
		return;
	}
	_data = value.substring(start+1,end).split(",");
	var param = funArr["param"];
	var i;
	for(i=0;i<param.length;i++){
		script.scriptArray.varList[param[i]] = _data[i];
	}
	var funLineArr = funArr["function"];
	for(i=funLineArr.length-1;i>=0;i--)script.lineList.unshift(funLineArr[i]);
	script.analysis();
	
};
ScriptFunction.setFunction = function (value){
	var script = LGlobal.script;
	var startNameIndex = value.indexOf(" ");
	var child;
	var funArr = new Array();
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	var strParam = value.substring(start + 1,end);
	var param = strParam.split(",");
	funArr["param"] = new Array();
	var i;
	for(i=0;i<param.length;i++){
		param[i] = LMath.trim(param[i]);
		if(param[i].length > 0)	{
			funArr["param"].push("param_" + param[i]);
		}
	}
	funArr["name"] = LMath.trim(value.substring(startNameIndex + 1,start));
	
	var funLineArr = new Array();
	while(script.lineList[0].indexOf("endfunction") < 0){
		child = script.lineList.shift();
		for(i=0;i<param.length;i++){
			if(param[i].length > 0)	child = child.replace("@"+param[i],"@param_"+param[i]);
		}
		funLineArr.push(child);
	}
	script.lineList.shift();
	funArr["function"] = funLineArr;
	script.scriptArray.funList[funArr["name"]] = funArr;
	script.analysis();
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptIF.js
**/
var ScriptIF = function (){};
ScriptIF.getIF = function (value){
	trace("getIF");
	var script = LGlobal.script;
	var startifIndex = 0;
	var endifIndex = 0;
	var ifArr;
	var childArray = new Array();
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	var str = value.substring(start + 1,end);
	ifArr = str.split("&&");
	trace("checkCondition");
	var ifvalue = ScriptIF.checkCondition(ifArr);
	trace("checkCondition over");
	var ifvalueend = false;
	var sCount = 0;
	var eCount = 0;
	
	while(startifIndex<script.lineList.length){
		sCount = 0;
		
		if(script.lineList[startifIndex].indexOf("elseif") >= 0){
			if(ifvalue){
				ifvalueend = true;
				startifIndex++;
				continue;
			}
			start = script.lineList[startifIndex].indexOf("(");
			end = script.lineList[startifIndex].indexOf(")");
			str = script.lineList[startifIndex].substring(start + 1,end);
			str = ScriptVarlable.getVarlable(str);
			ifArr = str.split("&&");
			ifvalue = ScriptIF.checkCondition(ifArr);
			startifIndex++;
			continue;
		}else if(script.lineList[startifIndex].indexOf("else") >= 0){
			if(ifvalue){
				ifvalueend = true;
				startifIndex++;
				continue;
			}
			ifvalue = true;
			endifIndex = startifIndex;
			startifIndex++;
			continue;
		}else if(script.lineList[startifIndex].indexOf("endif") >= 0){
			startifIndex++;
			break;
		}else if(script.lineList[startifIndex].indexOf("if") >= 0){
			if(ifvalue && !ifvalueend){
				childArray.push(script.lineList[startifIndex]);
			}
			startifIndex++;
			sCount = 1;
			eCount = 0;
			while(sCount > eCount){
				if(script.lineList[startifIndex].indexOf("if") >= 0 && 
					script.lineList[startifIndex].indexOf("else") < 0 && 
					script.lineList[startifIndex].indexOf("end") < 0){
					sCount++;
				}else if(script.lineList[startifIndex].indexOf("endif") >= 0){
					eCount++;
				}
				if(ifvalue && !ifvalueend){
					childArray.push(script.lineList[startifIndex]);
				}
				startifIndex++;
			}
		}
		if(sCount==0){
			if(ifvalue && !ifvalueend){
				childArray.push(script.lineList[startifIndex]);
			}
			startifIndex++;
		}
	}
	script.lineList.splice(0,startifIndex);
	
	for(var i=childArray.length - 1;i>=0;i--){
		trace("childArray["+i+"] = " + childArray[i]);
		script.lineList.unshift(childArray[i]);
	}
	
	script.analysis();
};
ScriptIF.checkCondition = function (arr){
	trace("ScriptIF.checkCondition = " + arr);
	for(var i = 0;i<arr.length;i++){
		if(!ScriptIF.condition(arr[i])){
			return false;
		}	
	}
	return true;
};
ScriptIF.condition = function (value){
	trace("ScriptIF.condition = " + value);
	var arr;
	if(value.indexOf("===") >= 0){
		//===
		arr=ScriptIF.getCheckStr(value,"===");
		return arr[0] == arr[1];
	}else if(value.indexOf("!==") >= 0){
		//!==
		arr=ScriptIF.getCheckStr(value,"!==");
		return arr[0] != arr[1];
	}else if(value.indexOf("==") >= 0){
		//==
		arr=ScriptIF.getCheckInt(value,"==");
		return arr[0] == arr[1];
	}else if(value.indexOf("!=") >= 0){
		//!=
		trace('value.indexOf("!=")');
		arr=ScriptIF.getCheckInt(value,"!=");
		return arr[0] != arr[1];
	}else if(value.indexOf(">=") >= 0){
		//>=
		arr=ScriptIF.getCheckInt(value,">=");
		return arr[0] >= arr[1];
	}else if(value.indexOf("<=") >= 0){
		//<=
		arr=ScriptIF.getCheckInt(value,"<=");
		return arr[0] <= arr[1];
	}else if(value.indexOf(">") >= 0){
		//>
		arr=ScriptIF.getCheckInt(value,">");
		return arr[0] > arr[1];
	}else if(value.indexOf("<") >= 0){
		//<
		arr=ScriptIF.getCheckInt(value,"<");
		return arr[0] < arr[1];
	}
	return false;
};
ScriptIF.getCheckInt = function (value,s){
	var arr;
	arr = value.split(s);
	arr[0] = parseInt(arr[0]);
	arr[1] = parseInt(arr[1]);
	
	return arr;
};
ScriptIF.getCheckStr = function (value,s){
	var arr;
	arr = value.split(s);
	arr[0] = LMath.trim(arr[0].replace('"',''));
	arr[1] = LMath.trim(arr[1].replace('"',''));
	
	
	return arr;
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptImg.js
**/
var ScriptImg = function (){};
ScriptImg.analysis = function (value,start,end){
	
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	switch(value.substr(0,start)){
		case "Img.add":
			ScriptImg.addImg(value,start,end);
			break;
		case "Img.changeData":
			//changeData(value,start,end);
			break;
		case "Img.transition":
			//transition(value,start,end);
			break;
		case "Img.moveTo":
			//moveTo(value,start,end);
			break;
		case "Img.remove":
			//removeImg(value,start,end);
			break;
	}
};
ScriptImg.addImg = function (value,start,end){
	var script = LGlobal.script;
	var layer;
	
	var lArr = value.substring(start+1,end).split(",");
	var layerStr = lArr[0];
	var nameStr = lArr[1];
	var dataStr = lArr[2];
	var bitdata;
	
	if(lArr.length > 8){
		//bitdata = LGlobal.getBitmapData(script.scriptArray.swfList[lArr[8]],dataStr);
	}else{
		bitdata = script.scriptArray.bitmapdataList[dataStr];
	}
	var xInt = parseFloat(lArr[3]);
	var yInt = parseFloat(lArr[4]);
	var wNum;
	var hNum;
	if(lArr.length > 5){
		wNum = parseFloat(lArr[5]);
	}
	if(lArr.length > 6){
		hNum = parseFloat(lArr[6]);
	}
	var alphaNum = 1;
	if(lArr.length > 7){
		alphaNum = parseFloat(lArr[7]);
	}
	
	layer = script.scriptArray.layerList[layerStr];
	trace("bitdata = " + bitdata);
	var bitmap = new LBitmap(bitdata);
	bitmap.width = wNum;
	bitmap.height = hNum;
	bitmap.alpha = alphaNum;
	bitmap.x = xInt;
	bitmap.y = yInt;
	bitmap.name = nameStr;
	script.scriptArray.imgList[nameStr] = bitmap;
	layer.addChild(bitmap);
	script.analysis();
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* ScriptButton.js
**/
var ScriptButton = function (){};
ScriptButton.analysis = function (value){
	var start = value.indexOf("(");
	var end = value.indexOf(")");
	trace("ScriptButton.analysis "+value.substr(0,start));
	switch(value.substr(0,start)){
		case "Button.add":
			ScriptButton.addButton(value,start,end);
			break;
		case "Button.remove":
			//removeButton(value,start,end);
			break;
		case "Button.mousedown":
			ScriptButton.mousedown(value,start,end,LMouseEvent.MOUSE_DOWN);
			break;
		case "Button.mouseup":
			ScriptButton.mousedown(value,start,end,LMouseEvent.MOUSE_UP);
			break;
		case "Button.mouseover":
			ScriptButton.mousedown(value,start,end,LMouseEvent.MOUSE_OVER);
			break;
		case "Button.mouseout":
			ScriptButton.mousedown(value,start,end,LMouseEvent.MOUSE_OUT);
			break;
		case "Button.setFilter":
			//setFilter(value,start,end);
			LGlobal.script.analysis();
			break;
		default:
			
	}
};
ScriptButton.addButton = function (value,start,end){
	var script = LGlobal.script;
	var layer;
	var lArr = value.substring(start+1,end).split(",");
	var layerStr = lArr[0];
	var nameStr = lArr[1];
	var labelStr = lArr[2];
	var x = parseInt(lArr[3]);
	var y = parseInt(lArr[4]);
	var dataUp = lArr[5];
	var dataOver = lArr[6];
	var dataDown = lArr[7];
	var upimg;
	var overimg;
	var downimg;
	if(lArr.length > 9){
		//upimg = LGlobal.getBitmapData(script.scriptArray.swfList[lArr[9]],dataUp);
		//overimg = LGlobal.getBitmapData(script.scriptArray.swfList[lArr[9]],dataOver);
		//downimg = LGlobal.getBitmapData(script.scriptArray.swfList[lArr[9]],dataDown);
	}else{
		upimg = script.scriptArray.bitmapdataList[dataUp];
		overimg = script.scriptArray.bitmapdataList[dataOver];
		downimg = script.scriptArray.bitmapdataList[dataDown];
	}
	var btn = new LButton(new LBitmap(upimg),new LBitmap(overimg),new LBitmap(downimg));
	btn.x = x;
	btn.y = y;
	if(lArr.length > 8){
		btn.labelColor = lArr[8];
	}
	btn.label = labelStr;
	layer = script.scriptArray.layerList[layerStr];
	script.scriptArray.btnList[nameStr] = btn;
	btn.name = nameStr;
	layer.addChild(btn);
	script.analysis();
};
ScriptButton.mousedown = function (value,start,end,e){
	var script = LGlobal.script;
	trace("ScriptButton.mousedown");
	var lArr = value.substring(start+1,end).split(",");
	var nameStr = lArr[0];
	var funStr = lArr[1];
	var btn = script.scriptArray.btnList[nameStr];
	var fun = function(event){
		ScriptFunction.analysis("Call." + funStr + "();");
	};
	trace("ScriptButton.fun"+fun);
	btn.addEventListener(e,fun);
	script.scriptArray.btnList[nameStr] = btn;
	trace("ScriptButton.script.scriptArray.btnList[nameStr]"+script.scriptArray.btnList[nameStr]);
	
	script.analysis();
	
};

